package com.ruoyi.dm.component;

import cn.hutool.extra.spring.SpringUtil;
import com.ruoyi.common.constant.CollectFileTypeConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 数据策略类控制
 */
@Slf4j
@Component
public class DataStrategyManager {

    public DataStrategy switchStrategy(String fileType,String satellite,String dataType) {
        if (CollectFileTypeConstants.TYPE_TEMP.equals(fileType)) {
            if ("TIMED".equals(satellite)) {
                return SpringUtil.getBean(TempTimedDataStrategy.class);
            }else {
                return SpringUtil.getBean(TempTestDataStrategy.class);
            }
        } else if (CollectFileTypeConstants.TYPE_DEN.equals(fileType)) {
            if("FY3C".equals(satellite)) {
                //廓线 单独处理
                return SpringUtil.getBean(FY3CDataStrategy.class);
            }else if ("APOD".equals(satellite)){
                return SpringUtil.getBean(ApodDataStrategy.class);
            }else {
                //return SpringUtil.getBean(NewDenstiyDataStrategy.class);
                return SpringUtil.getBean(DenstiyDataStrategy.class);
            }

        } else if (CollectFileTypeConstants.TYPE_WIND.equals(fileType)) {
            switch (satellite) {
                case "Nimbus7":
                    return SpringUtil.getBean(WindNimbus7DataStrategy.class);
                case "TIMED":
                    return SpringUtil.getBean(WindTimedDataStrategy.class);
                case "UARS":
                    return SpringUtil.getBean(WindUarsDataStrategy.class);
                case "CHAMP":
                    return SpringUtil.getBean(WindChampDataStrategy.class);
                case "GRACEA":
                    return SpringUtil.getBean(WindGraceADataStrategy.class);
                case "GRACEB":
                    return SpringUtil.getBean(WindGraceBDataStrategy.class);
                case "GOCE":
                    return SpringUtil.getBean(WindGoceDataStrategy.class);
                default:
            }
        }else if (CollectFileTypeConstants.TYPE_RADAR.equals(fileType)) {
            if ("MH".equals(satellite)) {
                return SpringUtil.getBean(RadarMhDataStrategy.class);
            }else if ("BATH".equals(satellite)) {
                return SpringUtil.getBean(RadarBathDataStrategy.class);
            }

        }else if (CollectFileTypeConstants.TYPE_RADIO.equals(fileType)) {
            return SpringUtil.getBean(RadioDataStrategy.class);
        }else if (CollectFileTypeConstants.TYPE_SUN.equals(fileType)) {
            return SpringUtil.getBean(SunDataStrategy.class);
        }else if (CollectFileTypeConstants.TYPE_EARTH.equals(fileType)) {
            return SpringUtil.getBean(EarthDataStrategy.class);
        }else if (CollectFileTypeConstants.TYPE_ANALYSIS.equals(fileType)) {
            return SpringUtil.getBean(ReAnalysisStrategy.class);
        }else if (CollectFileTypeConstants.TYPE_TLE.equals(fileType)) {
            return SpringUtil.getBean(TleDataStrategy.class);
        }else if (CollectFileTypeConstants.TYPE_TRACK.equals(fileType)) {
            if (CollectFileTypeConstants.TYPE_TRACK.equals(dataType)) {
                if (satellite.equals("GRACEFOC") || satellite.equals("GRACEFOD")) {
                    return SpringUtil.getBean(TrackGracefoStrategy.class);
                }else if (satellite.equals("CHAMP")) {
                    return SpringUtil.getBean(TrackChampStrategy.class);
                }

            }else if (CollectFileTypeConstants.TYPE_SHAPE.equals(dataType)) {
                if (satellite.equals("GRACEFOC") || satellite.equals("GRACEFOD")) {
                    return SpringUtil.getBean(ShapeGracefoStrategy.class);
                }else if (satellite.equals("CHAMP")) {
                    return SpringUtil.getBean(ShapeChampStrategy.class);
                }
            }
        }else if (CollectFileTypeConstants.TYPE_COND.equals(fileType)) {
            return SpringUtil.getBean(TleCondDataStrategy.class);
        }else if (CollectFileTypeConstants.TYPE_FALL.equals(fileType)) {
            return SpringUtil.getBean(FallDataStrategy.class);
        }
        return null;
    }
}
